package com.heatup.apt.management.service.impl;

import com.heatup.apt.common.dao.DataDictMapper;
import com.heatup.apt.management.service.DataDictService;
import com.heatup.apt.model.DataDict;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by b3st9u on 16/9/19.
 */
@Service
public class DataDictServiceImpl implements DataDictService {
    @Autowired
    DataDictMapper dataDictMapper;

    @Override
    public Map<String, Object> queryDictMap(String dictType) {
        //
    	  List<DataDict> list =  dataDictMapper.queryDataDictByDictTypeAndStatus(dictType, "1");
        Map<String, Object> map =null;
        if (list != null && list.size() > 0) {
            map = new HashMap<String, Object>();
            for(DataDict dict:list){
                map.put(dict.getDictCode(),dict.getDictName());
            }
        }
        return map;
    }

	@Override
	public List<DataDict> queryDataDicts(String dictType) {
		// TODO Auto-generated method stub
		return dataDictMapper.queryDataDictByDictTypeAndStatus(dictType, "1");
	}

}
